import QtQuick 2.5
import QtQuick.Window 2.2
import QtMultimedia 5.5
import Qt.labs.controls 1.0

Window {
    visible: true

    width: Screen.desktopAvailableWidth;
    height: Screen.desktopAvailableHeight;
    Item {
        width: Screen.desktopAvailableWidth;
        height: Screen.desktopAvailableHeight;
        Camera {
            id: camera
            captureMode: Camera.CaptureStillImage;
            position : Camera.FrontFace
            imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash

            exposure {
                exposureCompensation: -1.0
                exposureMode: Camera.ExposurePortrait
            }

            flash.mode: Camera.FlashRedEyeReduction

            imageCapture {
                onImageSaved: {
                    console.log("savePath:"+path);
                    Javeuser.useJavaFacerecognize(path);
                    var listinfo=QtMultimedia.availableCameras;
                    for( var i in listinfo)
                    {
                        console.log(i.deviceid+" "+i.displayName+" "+i.position+" "+i.orientation);
                    }

                }
            }
        }

        VideoOutput {
            source: camera
            anchors.fill: parent
            visible: false;
            focus : visible
        }

        Button{
            id:takecamera
            text: "B"
            height: parent.height/10;
            width: parent.width/3;
            anchors.centerIn: parent
            onClicked: {
                camera.start();
                camera.searchAndLock();
                camera.imageCapture.captureToLocation("/storage/emulated/0/data");///storage/emulater/0/data
            }
        }
        Connections{
            target: Javeuser
            onJavaFaceRecognizeOver:{
                console.log("savep:"+savePath);
                imageview.source="file://"+savePath;
                imageview.visible=true;
            }
        }

        Image {
            id: imageview
//            source: "/storage/emulated/0/data/IMG_00000004s.png"
//            visible: true;
            anchors.fill: parent
        }
    }
}
